//
//  PKPriceModal.swift
//  GoAbroad
//
//  Created by Pink Snow on 2025/5/16.
//

import Foundation
import UIKit
import ObjectMapper
class PKPriceModal: Mappable {
    var buttonText: String?
    var code: String?
    var description: String?
    var features: String?
    var isPopular: Bool = false
    var name: String?
    var price: Double = 0.0
    var usageLimit: Int = 0
    var productID : String?

    required init?(map: Map) {}

    func mapping(map: Map) {
        buttonText   <- map["button_text"]
        code         <- map["code"]
        description  <- map["description"]
        features     <- map["features"]
        isPopular    <- (map["is_popular"], BoolTransform())
        name         <- map["name"]
        price        <- map["price"]
        usageLimit   <- map["usage_limit"]
        productID <- map["product_id"]
    }
}
class BoolTransform: TransformType {
    typealias Object = Bool
    typealias JSON = Int

    func transformFromJSON(_ value: Any?) -> Bool? {
        if let intVal = value as? Int {
            return intVal != 0
        }
        return nil
    }

    func transformToJSON(_ value: Bool?) -> Int? {
        return value == true ? 1 : 0
    }
}
